extends ../layout

block content
  .pb-2.mt-2.mb-4.border-bottom
    h2
      i.fas.fa-network-wired.fa-sm.me-2(style='color: #6f42c1')
      | Together AI - One-shot LLM API call example

  .btn-group.mb-4.d-flex(role='group')
    a.btn.btn-primary.w-100(href='https://api.together.ai', target='_blank')
      i.fas.fa-table-columns.fa-sm.me-2
      | Together AI Dashboard
    a.btn.btn-primary.w-100(href='https://docs.together.ai/docs/inference', target='_blank')
      i.fas.fa-info.fa-sm.me-2
      | Together AI Docs
    a.btn.btn-primary.w-100(href='https://docs.together.ai/reference/chat-completions', target='_blank')
      i.fas.fa-book.fa-sm.me-2
      | API Reference

  p.text-muted
    | Analyze a customer message using #{ togetherAiModel } hosted on Together.AI to determine the appropriate department for routing. The system prompt provides classification instructions and requests the LLM to respond in JSON format, which the application can parse for further actions.

  .row
    .col-md-8.col-lg-6
      form(method='POST', action='/ai/togetherai-classifier')
        input(type='hidden', name='_csrf', value=_csrf)
        .mb-3
          label(for='inputText') Customer message
          textarea#inputText.form-control(name='inputText', maxlength='300', rows='4', required)= input
          .form-text.text-muted Maximum 300 characters.
        button.btn.btn-primary(type='submit') Classify Department

      if error
        .alert.alert-danger.mt-3= error

      if result
        .mt-4
          h5.text-secondary.mb-3 Classification (Routing) Result
          .d-flex.align-items-center.mb-2
            i.fas.fa-tag.me-2(style='color: #6f42c1')
            if result.department && result.department !== 'Unknown'
              span.fw-bold.text-primary.fs-4 Department:
              span.ms-2.fs-4= result.department
            else
              span.text-warning Could not determine department.
          if result.raw
            details
              summary Show raw model output
              pre.mt-2= result.raw
          if result.systemPrompt
            details
              summary Show system prompt
              pre.mt-2(style='white-space: pre-wrap; word-break: break-word')= result.systemPrompt
          if result.userPrompt
            details
              summary Show user prompt
              pre.mt-2= result.userPrompt
